package com.sanyang.lawyer.service.client;

import com.sanyang.lawyer.entity.*;
import com.sanyang.lawyer.mapper.client.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ClientService {

    @Autowired
    private ClientMapper clientMapper;
    @Autowired
    private Client_messageMapper client_messageMapper;
    @Autowired
    private Client_typeMapper client_typeMapper;
    @Autowired
    private Client_stateMapper client_stateMapper;
    @Autowired
    private Case_clientMapper case_clientMapper;
    //通过客户编号查询
    public Client getbyid(int clientid){
        return this.clientMapper.getbyid(clientid);
    }

    //查询所有客户
    public List<Client> listall(){
        return this.clientMapper.listall();
    }
    //通过客户信心编号查询客户信息
    public Client_message getbymessageid(int messageid){
        return this.client_messageMapper.getbymessageid(messageid);
    }
    //通过客户类型编号查询类型
    public Client_type getbytypeid(int typeid){
        return this.client_typeMapper.getbyid(typeid);
    }
    public Client_state getbystateid(int stateid){
        return this.client_stateMapper.getbyid(stateid);
    }
    //查询所有的客户类型
    public List<Client_type> listtypeall(){
        return this.client_typeMapper.listall();
    }
    //获取客户表的数据总数
    public int getcount(Map<String,Object> map){
        return this.clientMapper.getcount(map);
    };
    //获取所有对方当事人数量
    public int getcountprivy(Map<String,Object> map){
        return  this.clientMapper.getcountprivy(map);
    };
    //根据名称查询类型
    public int getbytypename(String typename){
        return  this.client_typeMapper.getbyname(typename);
    }
    //查询所有的状态
    public List<Client_type> liststateall(){
       return this.client_typeMapper.listall();
    }
    //添加信息
    public void insertOne(Client client){
        clientMapper.insertOne(client);
    }
    //修改客户详细信息
    public void updatemessage(Client_message message){
        client_messageMapper.updatemessage(message);
    }
    //查询所有的当事人
    public List<Client> listprivyall(Map<String,Object> map){
        List<Client> clients = clientMapper.listprivyall(map);
        return clients;
    }
    //修改对方当事人信息
    public void updateclient(Client client){
        this.clientMapper.updateclient(client);
    };
    //分页高级查询
    public List<Client> listallpage(Map<String,Object> map){
        return this.clientMapper.listallpage(map);
    };

    //以客户名称查询
    public Client getbyname(String clientName){
        return this.clientMapper.getbyname(clientName);
    }
}
